package com.focusai.efairy;

import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.facebook.stetho.Stetho;
import com.focusai.efairy.config.AppConfig;
import com.focusai.efairy.network.utils.UrlUtils;
import com.focusai.efairy.utils.BuglyUtils;
import com.focusai.efairy.utils.JiGuangPushUtil;
import com.focusai.efairy.utils.log.Log;

import io.rong.imlib.RongIMClient;
import io.rong.push.RongPushClient;

/**
 * Created by luo_guangwen on 2017/7/7.
 */

public class EFApplication extends MultiDexApplication {
    private static final String TAG = EFApplication.class.getName();

    private static Context mContext;

    @Override
    public void onCreate() {
        super.onCreate();
        this.mContext = getApplicationContext();
        initRongYun();
        BuglyUtils.initBugly();
        JiGuangPushUtil.initJiGuangPush();
        if (Log.isDebug()){
            Stetho.initializeWithDefaults(this);
        }

    }



    /**
     *电次元app
     * */
    public static boolean isEfairyApp(){
        return BuildConfig.APP_TYPE == AppConfig.APP_EFAIRY;
    }

    /**
     *中城物联app
     * */
    public static boolean isCciotApp(){
        return BuildConfig.APP_TYPE == AppConfig.APP_CCIOT;
    }
    public static Context getContext() {
        return mContext;
    }

    private void initRongYun() {
        try{
            String manufacturer = com.focusai.efairy.utils.DeviceUtils.getManufacturer();
            if("HUAWEI".equalsIgnoreCase(manufacturer)){
                RongPushClient.registerHWPush(mContext);
            }else if("Xiaomi".equalsIgnoreCase(manufacturer)){
                RongPushClient.registerMiPush(mContext, AppConfig.XIAOMI_APP_ID, AppConfig.XIAOMI_APP_KEY);
            }

            RongIMClient.init(mContext, UrlUtils.getRongYunAppkey());
        }catch (Exception e){
            RongIMClient.init(mContext, UrlUtils.getRongYunAppkey());
            e.printStackTrace();
        }
    }


//    PushJumpUtils.jumpToHomeActivityFormPush2(getContext(), 1364, "111111111111111");



}
